package hhh.file;
import java.io.File;
import java.util.Arrays;
import java.util.List;


public class FileTest {
	public static void main(String[] args) {
		doCopyDirs();

		//vivivan27 is not to sam16

	}
	/**
	 * 指定的目录复制，以及相应的子目录
	 */
	private static void doCopyDirs() {
		String srcFilePath = "E:/workspaces/eclipse/git";
		String descFilePath = "E:/workspaces/AndroidStudio/study/git";
		String[] need_dirs = {
				"completion_project","test",
				"tools","views",
				};
		String[] no_need_dirs = {
				".metadata","LaunchTest",
				"LibTest","RemoteSystemsTempFiles",
				"ViewTest",
		};
		List<String> need_dir_list = Arrays.asList(need_dirs);
		List<String> no_need_dir_list = Arrays.asList(no_need_dirs);
		getCopyFileDirByPoint(srcFilePath,descFilePath,need_dir_list,no_need_dir_list);
	}

	private static void getCopyFileDirByPoint(String srcFilePath, String descFilePath,
			List<String> need_dir_list, List<String> no_need_dir_list) {
		File srcFile = new File(srcFilePath);
		File descFile = new File(descFilePath);
		for (File childDir : srcFile.listFiles()) {
			String childDirName = childDir.getName();
			
			if (!no_need_dir_list.contains(childDirName)) {
				String subStr = childDirName.substring(0,1);
				if (subStr.matches("^[0-9]*$")
						||need_dir_list.contains(childDirName)
						) {
					if (childDir.isDirectory()) {
						System.out.println(childDirName);
						File createDescChildDir = new File(descFile,childDirName);
						if (!createDescChildDir.exists()) {
							createDescChildDir.mkdirs();
						}
						getCopyFileDirByPoint(childDir.getAbsolutePath(),createDescChildDir.getAbsolutePath(),need_dir_list,no_need_dir_list);
					}
				}
			}
			
		}
	}
}
